set "source=%cd%\"
cd..
set "dist=%cd%\cpyTREX-bin\"
if exist %dist% (
  cd %dist%
  if exist trex.exe (del /f/s/q trex.exe)
  if exist trex32.exe (del /f/s/q trex32.exe)
  if exist trex64.exe (del /f/s/q trex64.exe)
) else (mkdir %dist%)
cd %source%
set "py32=D:\Python\Python38-32\Scripts\"
if exist %py32% (
  %py32%pyinstaller --noconfirm --onefile --console --paths "./uses" --distpath "../cpytrex-bin" "./trex.py"
  del /f/s/q trex.spec
  rd build /s/q
  cd %dist%
  ren trex.exe trex32.exe
  cd %source%
)
pyinstaller --noconfirm --onefile --console --paths "./uses" --distpath "../cpytrex-bin" "./trex.py"
del /f/s/q trex.spec
rd build /s/q
if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
  cd %dist%
  ren trex.exe trex64.exe
)
copy %source%trex_ext.py %dist%trex_ext.py
copy %source%err_code.cfg %dist%err_code.cfg
copy %source%family_id.cfg %dist%family_id.cfg
start %dist%
